import mongoose from 'mongoose';
import { formatDateByNow } from '~/utils/util.date';

export interface IAdminPermission extends mongoose.Document {
	name: string;
	description: string;
	createdAt?: string;
	updatedAt?: string;
}

// 后台管理员权限
const AdminPermissionSchema = new mongoose.Schema<IAdminPermission>(
	{
		name: {
			type: String,
			required: true,
			unique: true,
		},
		description: {
			type: String,
		},
		createdAt: {
			type: String,
			default: formatDateByNow(),
		},
		updatedAt: {
			type: String,
			default: formatDateByNow(),
		},
	},
	{
		collection: 'admin_permissions',
	}
);

export const AdminPermissionModel = mongoose.model('AdminPermission', AdminPermissionSchema);
